using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint;
using System.IO;
using System.Configuration;

namespace SULK_Configurator
{
    class LogSettings
    {


        public static bool SetDefaultLogSettings()
        {
            
            try
            {
                //make sure directory exists
                if (!Directory.Exists(Properties.Settings.Default["UsageLogPath"].ToString()))
                {
                    Directory.CreateDirectory(Properties.Settings.Default["UsageLogPath"].ToString());
                    Directory.CreateDirectory(Properties.Settings.Default["ArchiveLogPath"].ToString());
                }

                //SPFarm farm = SPFarm.Local;

                //SPWebService webService = SPWebService.AdministrationService.UsageSettings;

                SPUsageSettings usageSettings = SPWebService.AdministrationService.UsageSettings;

                usageSettings.LoggingEnabled = true;
                usageSettings.NumberLogFiles = 5;
                usageSettings.LogFilesDirectory = Properties.Settings.Default["UsageLogPath"].ToString();
                usageSettings.UsageProcessingEnabled = true;

                usageSettings.SetProcessingInterval(1, 15, 1, 15);

                usageSettings.Update(false);
                
                
                
                
            }
            catch
            {
                return false;
            }

            return true;

        }
    }
}
